<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<div id="user_userPic_data" style="background-color:#F2F2F2;">
	<ul class="userPic_ul">
		<li class="userPic_ul_firstli">通&nbsp;过</li>
		<li style="width:3px; height:100%; border-left:1px solid #999;float:left"></li>
		<li class="userPic_ul_secondli">不通过</li>
		<li style="width:3px; height:100%; border-left:1px solid #999;float:left"></li>
		<li class="userPic_ul_li" id="userPic_allSelect">全&nbsp;选</li>
		<li style="width:3px; height:100%; border-left:1px solid #999;float:left"></li>
		<li class="userPic_ul_li" id="userPic_notSelect">全不选</li>
	</ul>
	<ul class="userPic_search">
		<li><input type="button" id="pic_search" value="查   询" style="color:green;"/></li>
		<li style="width:140px;">类型：<select id="pic_search_type" style="width:80px;"></select></li>
		<li style="width:120px;">年龄：<select id="pic_search_age" style="width:50px;"></select></li>
		<li style="width:200px;">条件搜索：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;性别：<select id="pic_search_sex"><option> 男 </option><option> 女 </option></select></li>
	</ul>
	
	<br />
	<div id="user_pic" style="width:1075px;">
		<div class="infor_pic"  onClick="javascript:selectPic(this)">
		<!--  
			<div class="pic_left">
				<h3 >会员信息</h3>
				<strong>昵称：</strong><span>${item.nickname }</span><br> 
                <strong>性别：</strong><span>${item.sex }</span><br> 
                <strong>年龄：</strong><span>${item.temp1 }</span><br>
                <strong>类型：</strong><span>${item.looks }</span><br>
			</div>
			<div class="pic_right">
				<input class="selectbox" type="checkbox" value="${item.buid }" style="position:absolute;"> 
				<img src="${item.touxiang }" onClick="javascript:selectPic(this)"></input>
			</div>
			-->
		</div>
	</div>
</div>
<script type="text/javascript">
	function showInfo(data){
		$("#user_pic").html("");//清空数据
    	var userPicDiv="";
		$.each(data, function(indexs, items){
    		$.each(items,function(index,item){
        		userPicDiv+='<div class="infor_pic"  onClick="javascript:selectPic(this)"><div class="pic_left">'
        			+'<h3 >会员信息</h3><strong>昵称：</strong><span>'+item.nickname+'</span><br> <strong>性别：</strong><span>'+item.sex +'</span><br> '
        			+'<strong>年龄：</strong><span>'+item.temp1 +'</span><br><strong>类型：</strong><span>'+item.looks +'</span><br></div>'
        			+'<div class="pic_right"><input class="selectbox" type="checkbox" value="'+item.buid +'" style="position:absolute;"> '
        			+'<img src="../'+item.touxiangs +'" onClick="javascript:selectPic(this)"></input></div></div>'
    		});
        });
    	$("#user_pic").html(userPicDiv);
	}


	$(function(){
		var options;
		for(var i=18;i<=50;i++){
			options+="<option> "+i+" </option>";
		}
		$("#pic_search_age").html(options);//年龄输入框赋值
		
		//获取未审核的会员头像信息
		$.ajax({
			type: "post",
            url: "../adminUserServlet?op=UserPicData",
            dataType:"json",
            success:function(data){
            	$.ajax({
            		type: "post",
                    url: "../adminUserServlet?op=getTypeData&sex=boy",
                    dataType:"json",
                    success:function(data){
                    	var soption;
						$.each(data,function(index,item){
							$.each(item,function(index,items){
								soption+="<option>"+items.LOOKS+"</option>";
							});
						});
		            	$("#pic_search_type").html(soption);
                    }
            	});
            	showInfo(data);//显示用户头像信息
            }
		});
		
		//当选择性别的选择框改变时
		$("#pic_search_sex").change(function(){
			var sex=$("#pic_search_sex").val();
			if(sex=="男"){
				sex="boy";
			}else{
				sex="girl";
			}
			
			$.ajax({
        		type: "post",
                url: "../adminUserServlet?op=getTypeData&sex="+sex,
                dataType:"json",
                success:function(data){
                	var soption;
					$.each(data,function(index,item){
						$.each(item,function(index,items){
							soption+="<option>"+items.LOOKS+"</option>";
						});
					});
	            	$("#pic_search_type").html(soption);
                }
        	});
		})
		
		
		
		//点击通过
		$(".userPic_ul_firstli").click(function(){
			var buid="";
			var obj=$(".infor_pic .selectbox");
			for(var i=0;i<obj.size();i++){
				if(obj[i].checked){
					buid+=obj[i].value+",";
				}
			}
			buid=buid.substring(0, buid.lastIndexOf(","));
			//console.info(buid);
			$.ajax({
				type:"post",
				url:"../adminUserServlet?op=allPicPass",
				data:{buids:buid,status:1},
				dataType:"json",
				success:function(data){
					if(data==0){
						alert("操作失败！");
					}else{
						$.messager.show({
							title:'成功提示',
							msg:'会员头像审核通过成功...',
							timeout:3000,
							showType:'slide'
						});
						//$("user_pic".hide());
						//console.info($("#user_pic").html);
						showInfo(data);//页面刷新
					}
				}
			});
		});
		//点击不通过
		$(".userPic_ul_secondli").click(function(){
			var buid="";
			var obj=$(".infor_pic .selectbox");
			for(var i=0;i<obj.size();i++){
				if(obj[i].checked){
					buid+=obj[i].value+",";
				}
			}
			buid=buid.substring(0, buid.lastIndexOf(","));
			//console.info(buid);
			$.ajax({
				type:"post",
				url:"../adminUserServlet?op=allPicPass",
				data:{buids:buid,status:2},
				dataType:"json",
				success:function(data){
					if(data==0){
						alert("操作失败！");
					}else{
						$.messager.show({
							title:'成功提示',
							msg:'会员头像审核不通过成功...',
							timeout:3000,
							showType:'slide'
						});
						//$("user_pic".hide());
						//console.info($("#user_pic").html);
						showInfo(data);//页面刷新
					}
				}
			});
		});
		//点击查询按钮
		$("#pic_search").click(function(){
			var sex=$("#pic_search_sex").val();
			var age=$("#pic_search_age").val();
			var type=$("#pic_search_type").val();
			$.ajax({
				type: "post",
	            url: "../adminUserServlet?op=searchPicData",
	            data:{sex:sex,age:age,type:type},
	            dataType:"json",
	            success:function(data){
	            	showInfo(data);
	            }
			});
		});
		//点击全选
		$("#userPic_allSelect").click(function(){
			$("#user_pic input").prop("checked",true);
			$(".infor_pic").css("color",'#06F').children().last().children().last().css("opacity","0.6");//图片模糊效果
		});
		//点击全不选
		$("#userPic_notSelect").click(function(){
			$("#user_pic input").prop("checked",false);
			$(".infor_pic").css("color",'#000').children().last().children().last().css("opacity","1");//图片模糊效果
		});
	});

	function selectPic(obj) {
		//console.info($(obj).children().last().children().first());
		var selectObj=$(obj).children().last().children().first();
		if(selectObj.prop("checked")){
			selectObj.prop("checked",false);
			$(obj).css("color",'#000').children().last().children().last().css("opacity","1");//图片模糊效果
		}else{
			//console.info(selectObj.val());
			selectObj.prop("checked",true);
			$(obj).css("color",'#06F').children().last().children().last().css("opacity","0.6");//图片模糊效果
		}
	}
</script>
